package com.itheima.demo01lambda;

import java.util.ArrayList;
import java.util.Collections;
import java.util.Comparator;
import java.util.List;

public class Demo02LambdaParam {
    public static void main(String[] args) {
        List<Person> list = new ArrayList<>();
        list.add(new Person("刘德华", 55, 172));
        list.add(new Person("张学友", 58, 174));
        list.add(new Person("黎明", 56, 175));
        list.add(new Person("郭富城", 53, 170));

//        Collections.sort(list, new Comparator<Person>() {
//            @Override
//            public int compare(Person o1, Person o2) {
//                // 以年龄的升序排序
////                return o1.getAge() - o2.getAge();
//
//                // 以身高的降序配许
//                return o2.getHeight() - o1.getHeight();
//            }
//        });

        Collections.sort(list, (Person o1, Person o2) -> {
            return o1.getAge() - o2.getAge();
        });

        for (Person person : list){
            System.out.println(person.getName());
        }
    }
}
